<?php

Raise::load('core.helper.logging.RaiseLog');

/**
 * TestCoreRaiseLog class
 * Testing unit of 'phpraise/core/RaiseLog.php'
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
 * @package Raise.UnitTest.Test
 */
class TestCoreRaiseLog extends RaiseTest {
    
    public static function testClass(){
        self::assertClassExists('RaiseLog');
        self::assertClassExtends('RaiseLog', 'RaiseHelper');
        self::assertClassMethod('RaiseLog', 'write');
    }

    public static function testRunLog(){
        $log = new RaiseLog('tmp.log', 2048);
        self::assertObjectClass($log, 'RaiseLog');
        self::assertObjectClass($log->file(), 'RaiseFile');
        $log->write(new RaiseException('test', 1024));
        self::assertTrue($log->file()->exists());

        $file = $log->file();
        for($i = 0; $i < 50; $i++){
            $log->write(new RaiseException('test', 1024));
        }
        self::assertNotEqual($file, $log->file());

        $paths = RaiseFileSystem::pathSearch('tmp*.log');
        $i = $paths->iterator();
        while($k = $i->iterate()){
           unlink($k->value());
        }

        self::assertFalse($log->file()->exists());
    }

}
